var a = getApp();

Page({
    data: {
        searchText: "",
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1
    },
    onLoad: function(a) {},
    onReady: function() {},
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            networkLoading: !1
        });
    },
    getListData: function(t) {
        var e = this, o = t.detail.value;
        if ("" == o) return a.tips("请输入关键字搜索");
        this.data.searchText = o, this.initData();
        var n = a.getNetAddresss("plugin.present-project.frontend.project.index"), s = {
            search_kwd: o
        };
        a._postNetWork({
            url: n,
            data: s,
            success: function(t) {
                var o = t.data;
                if (1 != o.result) return a.tips(o.msg);
                e.data.total_page = o.data.person_list.last_page, e.data.total_page || (e.data.total_page = 0), 
                e.setData({
                    listData: o.data.person_list.data,
                    networkLoading: !0
                });
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = a.getNetAddresss("plugin.present-project.frontend.project.index"), o = {
                search_kwd: this.data.searchText,
                page: this.data.page
            };
            a._postNetWork({
                url: e,
                data: o,
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var o = t.data.listData.concat(e.data.person_list.data);
                        t.setData({
                            listData: o
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    getDetails: function(a) {
        var t = a.currentTarget.dataset.id, e = "/packageI/donation_project/donationProjectDetails/donationProjectDetails?id=".concat(t);
        wx.navigateTo({
            url: e
        });
    },
    onShareAppMessage: function() {}
});